﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IM.Manage.IDAL;
using IM.Manage.DALFactory;
using IM.Manage.Models;
using System.Linq.Expressions;

namespace IM.Manage.BLL
{
    public class BaseBLL<TEntity> where TEntity : BaseModel
    {
        protected readonly IBaseDAL<TEntity> dal = DataAccess<TEntity>.CreateDAL();

        public int GetMaxId()
        {
            return dal.GetMaxId();
        }
        public bool Exists(int id)
        {
            return dal.Exists(id);
        }
        public bool ExistsByCondition(Expression<Func<TEntity, bool>> expression)
        {
            return dal.ExistsByCondition(expression);
        }

        public int GetRecordCount()
        {
            return dal.GetRecordCount();
        }
        public int GetRecordCount(Expression<Func<TEntity, bool>> expression)
        {
            return dal.GetRecordCount(expression);
        }
        public IList<TEntity> GetList(Expression<Func<TEntity, bool>> expression)
        {
            return dal.GetList(expression);
        }
        public IList<TEntity> GetList()
        {
            return dal.GetList();
        }
        public TEntity GetEntity(int id)
        {
            return dal.GetEntity(id);
        }

        public int Create(TEntity t)
        {
            return dal.Create(t);
        }
        public int Update(TEntity t)
        {
            return dal.Update(t);
        }
        public int Delete(int id)
        {
            return dal.Delete(id);
        }

        public int UpdateByCondition()
        {
            return dal.UpdateByCondition();
        }
        public int DeleteByCondition()
        {
            return dal.DeleteByCondition();
        }
    }
}
